package com.wn.cleandemo.junk.bean;

import android.text.TextUtils;

import androidx.annotation.Nullable;


import com.wn.cleandemo.junk.JunkType;

import java.io.File;

/**
 * 文件类型，增加混淆破解难度
 */
public class JunkBigFile extends BaseJunk {
    //大文件
    public @JunkType.BigFileType
    int bigFileType;

    public JunkBigFile(@Nullable File file, int junkType) {
        super(file, junkType);
    }

    public void CheckType() {
        String str = this.name;
        String lowerCase = str.substring(str.lastIndexOf(".") + 1).toLowerCase();

        if (TextUtils.isEmpty(lowerCase)) {
            bigFileType = JunkType.BigFileType.J_Other;
        } else {
            bigFileType = JunkType.BigFileType.J_Other;

            if ("apk".equalsIgnoreCase(lowerCase)
            ) {
                bigFileType = JunkType.BigFileType.J_APK;
            } else if ("psd".equalsIgnoreCase(lowerCase)
                    || "pdf".equalsIgnoreCase(lowerCase)
                    || "txt".equalsIgnoreCase(lowerCase)
                    || "doc".equalsIgnoreCase(lowerCase)
                    || "docx".equalsIgnoreCase(lowerCase)
                    || "xls".equalsIgnoreCase(lowerCase)
                    || "xlsx".equalsIgnoreCase(lowerCase)
                    || "ppt".equalsIgnoreCase(lowerCase)
                    || "pptx".equalsIgnoreCase(lowerCase)
            ) {
                bigFileType = JunkType.BigFileType.J_DOC;
            } else if ("rm".equalsIgnoreCase(lowerCase)
                    || "3gp".equalsIgnoreCase(lowerCase)
                    || "avi".equalsIgnoreCase(lowerCase)
                    || "mp4".equalsIgnoreCase(lowerCase)
                    || "mov".equalsIgnoreCase(lowerCase)
                    || "rmvb".equalsIgnoreCase(lowerCase)
                    || "mpg".equalsIgnoreCase(lowerCase)
                    || "swf".equalsIgnoreCase(lowerCase)
                    || "mkv".equalsIgnoreCase(lowerCase)
            ) {
                bigFileType = JunkType.BigFileType.J_VIDEO;
            } else if ("cd".equalsIgnoreCase(lowerCase)
                    || "ape".equalsIgnoreCase(lowerCase)
                    || "mp3".equalsIgnoreCase(lowerCase)
                    || "wav".equalsIgnoreCase(lowerCase)
                    || "wma".equalsIgnoreCase(lowerCase)
            ) {
                bigFileType = JunkType.BigFileType.J_AUDIO;
            } else if ("gif".equalsIgnoreCase(lowerCase)
                    || "jpg".equalsIgnoreCase(lowerCase)
                    || "jpeg".equalsIgnoreCase(lowerCase)
                    || "png".equalsIgnoreCase(lowerCase)
                    || "bmp".equalsIgnoreCase(lowerCase)
            ) {
                bigFileType = JunkType.BigFileType.J_IMAGE;
            } else if ("zip".equalsIgnoreCase(lowerCase)
                    || "rar".equalsIgnoreCase(lowerCase)
                    || "gz".equalsIgnoreCase(lowerCase)
            ) {
                bigFileType = JunkType.BigFileType.J_ZIP;
            }
        }
    }
}
